<%@ page contentType="text/html;charset=utf-8" pageEncoding="UTF-8"%>
<%@include file="/common/common.jsp" %>

<html>
	<head>
		<title>会员管理_修改会员级别</title>
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/skin.css">
		<link href="${pageContext.request.contextPath}/css/jquery.alerts.css" rel="stylesheet" type="text/css" media="screen">		
		<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery/jquery-1.4.2.min.js"></script>
		<script src="${pageContext.request.contextPath}/js/jquery/jquery.ui.draggable.js" type="text/javascript"></script>
		<script src="${pageContext.request.contextPath}/js/jquery/jquery.alerts.js" type="text/javascript"></script>
		<script src="${pageContext.request.contextPath}/js/tools.js" type="text/javascript"></script>
		<style type="text/css">
			<!--
			body {
				margin-left: 0px;
				margin-top: 0px;
				margin-right: 0px;
				margin-bottom: 0px;
			}
			.STYLE1 {font-size: 12px}
			.STYLE3 {font-size: 12px; font-weight: bold; }
			.STYLE4 {
				color: #03515d;
				font-size: 12px;
			}
			-->
		</style>
		<script type="text/javascript">
			var name = "<s:property value="name"/>";
			var serialid = "<s:property value="serialid"/>";
			var description = "<s:property value="description"/>";
			var categoryId = "<s:property value="categoryId"/>";
			
			function onReturn(){
				location.href = "${pageContext.request.contextPath}/admin/member/gradeList.action";
			}

			function onReset(){
				gradeForm.description.value = description;
				gradeForm.category.value = categoryId;
				gradeForm.name.value = name;
			}

			function init(){
				onReset();
			}

			function onUpdate(){
				//验证
				if(gradeForm.name.value.trim() == ""){
					jAlert('warning', '级别名称不能为空!', '操作警告');
					gradeForm.name.focus();
					return false;
				}else{
					if(!checkedTextArea(gradeForm.name.value.trim(), 50, "级别名称")){
						categoryForm.name.focus();
						return false;
					}
				}

				if(gradeForm.category.value == "0"){
					jAlert('warning', '请选择所属的会员类别!', '操作警告');
					return false;
				}

				if(gradeForm.description.value.trim() != ""){
					if(!checkedTextArea(gradeForm.description.value.trim(), 1000, "级别描述")){
						gradeForm.description.focus();
						return false;
					}
				}

				//提交处理
				var url = "updateGrade.action";
				var params = {
						serialid:serialid,		
						name:$('#name').attr('value'),
						description:$('#description').val(),
						categoryId:$('#category').val()
					};
				$.post(url, params, callback, "json");
			}

			function callback(data){				
				if(data.results == "success"){
					name = data.name;
					description = data.description;
					categoryId = data.categoryId;
					jAlert('success', '修改会员级别成功!', '操作提示');
				}else
					jAlert('error', data.results, '操作提示');				
				
			}
		</script>
	</head>
	
	<body onload="init()">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td height="30" background="${pageContext.request.contextPath}/admin/images/main/tab_05.gif">
					<!-- 导航条 -->
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
			      		<tr>
			        		<td width="12" height="30"><img src="${pageContext.request.contextPath}/admin/images/main/left-top-right.gif" width="12" height="30" /></td>
			       			<td>
			       				<table width="100%" border="0" cellspacing="0" cellpadding="0">
			          				<tr>
			            				<td width="46%" valign="middle">
			            					<table width="100%" border="0" cellspacing="0" cellpadding="0">
			              						<tr>
			                						<td width="5%"><div align="center"><img src="${pageContext.request.contextPath}/admin/images/main/tb.gif" width="16" height="16" /></div></td>
			                						<td width="95%" class="STYLE1"><span class="STYLE3">你当前的位置</span>：[会员管理]-[会员级别]-[修改会员级别]</td>
			              						</tr>
			            					</table>
			            				</td>			            				
			          				</tr>
			        			</table>
			        		</td>
			        		<td width="16"><img src="${pageContext.request.contextPath}/admin/images/main/nav-right-bg.gif" width="16" height="30" /></td>
			      		</tr>			      		
			    	</table>
			    </td>
			</tr>
			
			<!-- 内容 -->
			  <tr>
			   <td>
			   		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			      		<tr>
			        		<td width="3">&nbsp;</td>
			  	  	 		<td><table width="100%" height="30" border="0" bgcolor="b5d6e6" cellpadding="0" cellspacing="1" class="nowtable">
              						<tr>
                						<td class="left_bt2">&nbsp;&nbsp;&nbsp;&nbsp;会员级别信息设置</td>
              						</tr>
            		 			</table>
            	 			</td>
            	 			<td width="3" >&nbsp;</td>
            	 		</tr>
            	 	</table>
            	 </td>
			  </tr>
			  
			  <s:form name="gradeForm" id="gradeForm" action="addGrade" method="post" namespace="/member" >
			  <tr>
			     <td>
			   		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			      		<tr>
			        		<td width="3">&nbsp;</td>
			  	  	 		<td><table width="100%" height="30" border="0" bgcolor="b5d6e6" cellpadding="0" cellspacing="0" class="nowtable">
              						 <tr>
                						<td width="20%" height="30" align="right" bgcolor="#f2f2f2" class="left_txt2">级别名称：</td>
                						<td width="3%" bgcolor="#f2f2f2">&nbsp;</td>
                						<td width="32%" height="30" bgcolor="#f2f2f2"><input type="text" id="name" name="name" size="32" maxlength="50" /></td>
                						<td width="45%" height="30" bgcolor="#f2f2f2" class="left_txt">（<font color="red">必填项</font>）</td>
              						 </tr>              						 
              						 <tr>
                						<td height="30" align="right" class="left_txt2">所属类别：</td>
                						<td>&nbsp;</td>
                						<td height="30">
                							<s:select list="categoryList" name="category" id="category" listKey="SERIALID" listValue="NAME" />
                						</td>
                						<td height="30" class="left_txt">（<font color="red">必填项</font>）</td>
              						</tr>
              						<tr>
                						<td width="20%" height="30" align="right" bgcolor="#f2f2f2" class="left_txt2">级别描述：</td>
                						<td width="3%" bgcolor="#f2f2f2">&nbsp;</td>
                						<td width="32%" height="30" bgcolor="#f2f2f2">
                							<textarea rows="8" cols="60" id="description" name="description"></textarea>
                						</td>
                						<td width="45%" height="30" bgcolor="#f2f2f2" class="left_txt"></td>
              						 </tr>   
            		 			</table>
            	 			</td>
            	 			<td width="3" >&nbsp;</td>
            	 		</tr>
            	 	</table>
            	 </td>
			  </tr>
			  
			  <tr>
              	  <td height="30">&nbsp;</td>
              </tr>
              <tr>
                  <td align="center">
              		  <input type=button value="&nbsp;保&nbsp;存&nbsp;" name="B1" onclick="onUpdate()" />
              		  &nbsp;&nbsp;
              		  <input type="button" value="&nbsp;重&nbsp;置&nbsp;" name="B12" onclick="onReset()" />
              		  &nbsp;&nbsp;
              		  <input type="button" value="&nbsp;返&nbsp;回&nbsp;" name="B2" onclick="onReturn()"/>
              	  </td>
     	      </tr>     	      
			 </s:form>
		</table>
	</body>
</html>